package com.hopes.bizz.poll.common.util;

import com.alibaba.fastjson.JSONObject;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author daijie
 * @version 1.0
 * @date 2023/6/1 20:14
 * @Description:
 */
public class OmDataJsonUtils {
    /**
     * 将 om dataJson 里不需要的因子去除掉
     *
     * @param dataJson
     * @param factorCodeList
     * @return
     */
    public static JSONObject filterFactorCode(JSONObject dataJson, List<String> factorCodeList){
        Set<String> removeCode = new HashSet<>();
        for (String code : dataJson.keySet()) {
            if (!factorCodeList.contains(code)) {
                removeCode.add(code);
            }
        }
        if (!removeCode.isEmpty()) {
            for (String code : removeCode) {
                dataJson.remove(code);
            }
        }

        return dataJson;
    }
}
